const Express = require('express');
const router = Express.Router();
const { routeWrapper } = require('../../../lib/module/tool/route');
const accountService = require('../../../lib/service/accountService');

// 获取账户余额
router.get('/:areaId/getaccountprice', routeWrapper(async (req) => {
    return accountService.getAccountPrice(req.params.areaId);
}, true));

// 提现
router.post('/:areaId/withdraw', routeWrapper(async (req, res, next) => {
    return accountService.withDraw(req.auth.adminId, req.params.areaId, req.body.price, req.body.realPrice, req.body.description);
}, true));

// 查询收入记录
router.post('/:areaId/incomeRecord/:offset/:rows', routeWrapper(async (req, res, next) => {
    return accountService.incomeRecord(req.params.areaId, req.params.offset, req.params.rows);
}, true));

// 查询提现记录
router.post('/:areaId/withdrawRecord/:offset/:rows', routeWrapper(async (req, res, next) => {
    return accountService.userWithdrawRecord(req.params.areaId, req.params.offset, req.params.rows);
}, true));

module.exports = router;
